import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app_test/test1.dart';
import 'package:flutter_app_test/test_activity2.dart';

main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      routes: {"activity2": (BuildContext context) => Activity2()},
      home: _Home(),
    );
  }
}

class _Home extends StatefulWidget {
  const _Home({Key? key}) : super(key: key);

  @override
  __HomeState createState() => __HomeState();
}

class __HomeState extends State<_Home> {
  _startActivity() async {
    var code = await Navigator.pushNamed(context, "activity2");
    pri(code);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        title: Text("我是界面1"),
      ),
      body: Center(
        child: Column(
          children: [
            Text("我是界面1"),
            ElevatedButton(onPressed: _startActivity, child: Text("跳转"))
          ],
        ),
      ),
    );
  }
}
